IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'instedd_fnb')
CREATE USER [instedd_fnb] FOR LOGIN [instedd_fnb] WITH DEFAULT_SCHEMA=[dbo]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserLocation]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserLocation](
	[facebookUserId] [varchar](50) NOT NULL,
	[lat] [float] NULL,
	[long] [float] NULL,
 CONSTRAINT [PK_UserLocation] PRIMARY KEY CLUSTERED 
(
	[facebookUserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserRegistry]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[UserRegistry](
	[facebookUserId] [varchar](50) NOT NULL,
	[sessionKey] [varchar](50) NOT NULL,
 CONSTRAINT [PK_UserRegistry] PRIMARY KEY CLUSTERED 
(
	[facebookUserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[UserPreferences](
	[facebookUserId] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[visibilityLevel] [int] NOT NULL CONSTRAINT [DF_UserPreferences_visibilityLevel]  DEFAULT ((0)),
	[nearbyRadiusKM] [int] NOT NULL CONSTRAINT [DF_UserPreferences_nearByRadiusKM]  DEFAULT ((50)),
	[twitterAlias] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_UserPreferences] PRIMARY KEY CLUSTERED 
(
	[facebookUserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
